package com.coolw.data.migrate.common.util;

import com.coolw.data.migrate.common.listener.event.BaseEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;

/**
 * 事件工具类
 *
 * @author coolw
 * @date 2024/2/21 12:55
 */
@Component
public class EventUtil {

    private static ApplicationEventPublisher eventPublisher;

    @Autowired
    public void setPublisher(ApplicationEventPublisher eventPublisher) {
        EventUtil.eventPublisher = eventPublisher;
    }

    public static <T> void publishEvent(BaseEvent<T> event) {
        eventPublisher.publishEvent(event);
    }
}
